home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / gufw / model / Log.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-11-02  |  2.6 KB  |  72 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import time
  5. import commands
  6. from Variable import Variable
  7.  
  8. class Log:
  9.     
  10.     def __init__(self):
  11.         self.variable = Variable()
  12.         self.msgs = []
  13.         self.wrapping = self.variable.get_constant('disabled')
  14.         self.status = self.init_status_log()
  15.  
  16.     
  17.     def init_status_log(self):
  18.         if not self.variable.dev:
  19.             log_recorder = commands.getstatusoutput(self.variable.get_command('get_log_file'))
  20.         else:
  21.             log_recorder = commands.getstatusoutput(self.variable.get_command('get_log_file_dev'))
  22.         if log_recorder[0] == 0:
  23.             log_split = log_recorder[1].split('\n')
  24.             for log_line in log_split:
  25.                 if log_line != '':
  26.                     self.msgs.append(log_line)
  27.                     continue
  28.             
  29.         
  30.         if not self.variable.dev:
  31.             command = commands.getstatusoutput(self.variable.get_command('cfg_gufw_log'))
  32.         else:
  33.             command = commands.getstatusoutput(self.variable.get_command('cfg_gufw_log_dev'))
  34.         if command[0] == 0:
  35.             return self.variable.get_constant('gufw_log_on')
  36.         return self.variable.get_constant('gufw_log_off')
  37.  
  38.     
  39.     def add_log(self, status, msg_log):
  40.         if status == self.variable.get_constant('gufw_log_off'):
  41.             return None
  42.         actual_time = '[' + time.strftime('%x %X') + '] '
  43.         msg = actual_time + str(msg_log)
  44.         self.msgs.append(msg)
  45.         if not self.variable.dev:
  46.             commands.getstatusoutput(self.variable.get_command('append_log_file').replace('&', msg))
  47.         else:
  48.             commands.getstatusoutput(self.variable.get_command('append_log_file_dev').replace('&', msg))
  49.  
  50.     
  51.     def get_log(self):
  52.         return self.msgs
  53.  
  54.     
  55.     def refresh_log(self):
  56.         self.msgs = []
  57.         if not self.variable.dev:
  58.             commands.getstatusoutput(self.variable.get_command('refresh_log_file'))
  59.         else:
  60.             commands.getstatusoutput(self.variable.get_command('refresh_log_file_dev'))
  61.  
  62.     
  63.     def set_wrapping(self, wrapping):
  64.         self.wrapping = wrapping
  65.         return wrapping
  66.  
  67.     
  68.     def get_wrapping(self):
  69.         return self.wrapping
  70.  
  71.  
  72.